package com.example.myapplication.customeView;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.opengl.GLSurfaceView;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.View;

import androidx.annotation.Nullable;

public class CarReverseView extends View {

    private Paint mPaint;



    public CarReverseView(Context context) {
        this(context, null);
    }

    public CarReverseView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public CarReverseView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        this(context, attrs, defStyleAttr, 0);
    }

    public CarReverseView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        init(context);
    }

    private void init(Context context) {
        mPaint = new Paint();
        mPaint.setColor(Color.GREEN);
        mPaint.setStrokeWidth(10);

    }

    @Override
    protected void onDraw(Canvas canvas) {

        DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
        int screenWidth = displayMetrics.widthPixels;
        int screenHeight = displayMetrics.heightPixels;
        canvas.drawLine((float)screenWidth / 2 -800,(float)screenHeight,(float)screenWidth / 2-200,(float)screenHeight/2,
                mPaint);
        canvas.drawLine((float)screenWidth / 2 -200,(float)screenHeight/2,(float)screenWidth / 2 +200,(float)screenHeight/2,
                mPaint);
        canvas.drawLine((float)screenWidth / 2 +200,(float)screenHeight/2,(float)screenWidth / 2 +800,(float)screenHeight,
                mPaint);
    }



}
